package com.zhong.kotlin.mvp.presenter

import android.util.Log
import com.hjtech.baselib.mvpbase.BasePresenterImpl
import com.hjtech.baselib.retroft.BaseApi
import com.hjtech.baselib.retroft.ExceptionHelper
import com.zhong.kotlin.mvp.contact.TestContact
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers


/*
 * 项目名:    KotlinFrame
 * 包名       com.zhong.kotlin.mvp.presenter
 * 文件名:    TestPresenter
 * 创建者:    ZJB
 * 创建时间:  2017/10/12 on 15:57
 * 描述:     TODO
 */
class TestPresenter(view: TestContact.view?) : BasePresenterImpl<TestContact.view>(view), TestContact.presenter {
    override fun getData() {
        BaseApi.getInstance().province.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnSubscribe({ disposable ->
                    addDisposable(disposable)
                })
                .subscribe({ t: String ->
                    view!!.setData(t)

                }, { t: Throwable ->
                    val exception = ExceptionHelper.handleException(t)
                    Log.e("aaaaa", exception)
                }
                )
    }

}